﻿using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.Domain.Entity;
using IntelligentAgriculture.WebAPI.Application.Command.VendorModelCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.VendorModelCommandHandler
{
	/// <summary>
	/// 供应商修改
	/// </summary>
	public class UpdateVendormodelsCommandHandler : IRequestHandler<UpdateVendormodelsCommand, Results<int>>
	{
		private readonly IVendorModelService _vendorModelService;
		public UpdateVendormodelsCommandHandler(IVendorModelService vendorModelService)
		{
			_vendorModelService = vendorModelService;
		}
		public async Task<Results<int>> Handle(UpdateVendormodelsCommand request, CancellationToken cancellationToken)
		{
			var entity = new Vendormodel()
			{
				ArearAdd = request.ArearAdd,
				BusinessId = request.BusinessId,
				CreateBy = request.CreateBy,
				CreateTime = request.CreateTime,
				IdentityCard = request.IdentityCard,
				IndustryName = request.IndustryName,
				IsDel = request.IsDel,
				Markets = request.Markets,
				Mnemonics = request.Mnemonics,
				ResponsibleName = request.ResponsibleName,
				ResponsiblePhone = request.ResponsiblePhone,
				Salesman = request.Salesman,
				UnifiedSocialCreditCode = request.UnifiedSocialCreditCode,
				UnitsOfReference = request.UnitsOfReference,
				UpdateBy = request.UpdateBy,
				UpdateTime = request.UpdateTime,
				UseState = request.UseState,
				VendorAttributes = request.VendorAttributes,
				VenDorCode = request.VenDorCode,
				VendorDesc = request.VendorDesc,
				VendorName = request.VendorName,
				VendorType = request.VendorType,
				VendorSnowId = request.VendorSnowId
			};
			var result = await _vendorModelService.UpdateVendormodels(entity);
			return Results<int>.DataResult(result);
		}
	}
}
